const ws = require("nodejs-websocket")

// Scream server example: "hi" -> "HI!!!" 
const server = ws.createServer(function (conn) {
    console.log("New connection");
    conn.on("text", function (str) {
        console.log("Received "+str);
        conn.sendText(str.toUpperCase()+"!!!");
    });
    conn.on("close", function (code, reason) {
        console.log("Connection closed", code, reason);
    });
    conn.on('error', function (err) {
        console.log('error', err);
    });
}).listen(8001);